package com.carrara.helloworld;

import java.util.Random;
import java.util.Scanner;

public class Adddveennttuurreeee {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		System.out.println("You come across a monster, do you want to fight with a punch, fight with a kick, or run?");

		int monsterhealth = 10;
		int yourhealth = 10;

		while (monsterhealth > 0 && yourhealth > 0) {

			System.out.println("Your health is " + yourhealth + ".");

			System.out.println("The monster's health is " + monsterhealth + ".");

			Scanner fightrun = new Scanner(System.in);

			String fightorrun = fightrun.next();

			if (fightorrun.equals("punch")) {

				Random rand = new Random();

				int random = rand.nextInt();

				if (random >= 3) {
					System.out.println("You have done damage.");
					monsterhealth -= 1;
				} else {
					System.out.println("You have recieved damage.");
					yourhealth -= 1;

				}
				
			}
				
			else if (fightorrun.equals("kick"))
			{
				Random randp = new Random();
				
				int randomp = randp.nextInt();
				
				if (randomp >= 0) {
					System.out.println("You have done damage.");
					monsterhealth -= 3;
				} else {
					System.out.println("You have recieved damage");
					yourhealth -= 2;
				}
					
			} else if (fightorrun.equals("run")) {
				Random rand2 = new Random();

				int random2 = rand2.nextInt();

				if (random2 <= 0) {
					System.out.println("You sucessfully ran away.");
					break;
				} else {
					System.out
							.println("You failed to run, you took triple damage.");
					yourhealth -= 3;
				}
			}
		}
		if (monsterhealth <= 0) {
			System.out.println("You beat the monster!");
		} else if (yourhealth <= 0) {
			System.out.println("You died!");
		} else {
			System.out.println();
		}

	}
}
